package cn.rengy.util.web;

import cn.rengy.util.servlet.ServletUtil;

import jakarta.servlet.http.HttpServletRequest;
import java.security.Principal;
import java.util.HashMap;
import java.util.Map;

public class RequestUtil {
    private static final Map<String,String> keyMapping=new HashMap<String,String>(2,1);
    static {
        keyMapping.put("initResourceSql", "select_all_sysResourceUri");

    }

    public static String getString(String key){
        return keyMapping.get(key);
    }
    public static String getUserAgent(Object request){
        HttpServletRequest _request=(HttpServletRequest)request;
        return ServletUtil.getUserAgent(_request);
    }

    public static String getHeader(Object request,String name){
        HttpServletRequest _request=(HttpServletRequest)request;
        return _request.getHeader(name);
    }

    public static String getClientIp(Object request){
        HttpServletRequest _request=(HttpServletRequest)request;
        return ServletUtil.getClientIp(_request);
    }
    public static Principal getPrincipal(){
        return ServletUtil.getPrincipal();
    }


    public static void setPrincipal(Principal principal){
        ServletUtil.setPrincipal(principal);
    }

    public static String getRequestPath(Object request){
        HttpServletRequest _request=(HttpServletRequest)request;
        return _request.getRequestURI();
    }

    public static String getRequestMethod(Object request){
        HttpServletRequest _request=(HttpServletRequest)request;
        return _request.getMethod();
    }
}
